package com.example.demo.controller.picture;

import com.example.demo.service.picture.PictureService;
import com.example.demo.vo.picture.PictureVO;
import com.example.demo.vo.ResultVO;
import org.springframework.web.bind.annotation.*;
import org.springframework.web.multipart.MultipartFile;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;

@RestController
@RequestMapping("/picture")
public class PictureController {
    @Resource
    PictureService pictureService;

    @PostMapping("/uploadPicture")
    public ResultVO<PictureVO> uploadApp(@RequestParam("file") MultipartFile picture){
        return pictureService.uploadPicture(picture);
    }
    @GetMapping("/download/{originName:.+}")
    public void download(@PathVariable String originName, @RequestParam String newName, HttpServletResponse response) {
        pictureService.downloadFile(originName, newName, response);
    }
}
